package es.pawer.patches.listener;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import es.pawer.web.checklists.data.Checklist;
import es.pawer.web.checklists.data.ChecklistDAO;
import es.pawer.web.checklists.data.ListItem;

/**
 * Just an initializer class for test purposes
 * @author plozano
 *
 */
public class MyServletContextListener implements ServletContextListener {

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		for (int i=1;i<4;i++) {
			Checklist cl= new Checklist();
			cl.setId((long) i);
			cl.setItems(new ArrayList<ListItem>());
			cl.setName("TO DO "+i);
			for (int j=0;j<4;j++) {
				ListItem item= new ListItem();
				item.setName("Item "+j);
				item.setDescription("Something to do "+i+" "+j);
				item.setValue(j);
				cl.getItems().add(item);
				ChecklistDAO.insertChecklist(cl);
			}
			
		}
		
	}
	

}
